<load file="__PUBLIC__/header.html"/>
<ul class="top_title">
    
    <li>
        <p class="menu_title">修改密码</p>
    </li>
</ul>
<form action="__METH__" method="post" name="addList">
    <table class="table">
        <thead>
            <tr>
                <th colspan="3">修改密码</th>
            </tr>
        </thead>
        <tbody>
            
            <tr>
                <td align="right" width="40%">旧密码：</td>
                <td align="left" width='150'>
                    <input type='password' name="oldupwd"/>
                </td>
                <td align="left"><span id='err1' style='display:none;color:#f60'>222</span></td>
            </tr>
            <tr>
                <td align="right" width="40%">新密码：</td>
                <td align="left">
                    <input type='password' name="newupwd" />
                </td>
                <td align="left"><span id='err2' style='display:none;color:#f60'>222</span></td>
            </tr>
            <tr>
                <td align="right" width="40%">重复新密码：</td>
                <td align="left">
                    <input type='password' name="roldupwd" />
                </td>
                <td align="left" ><span id='err3' style='display:none;color:#f60'>222</span></td>
            </tr>
           
            
            
            
            <tr>
                <td colspan="3" align="center">
                    <input type="submit" class="menu_submit" value="提交修改"/>
                </td>
            </tr>
        </tbody>
    </table>
</form>
<script type='text/javascript'>
    $(function (){
        $('.menu_submit').click(function(){

            //旧密码验证
            if($("input[name=oldupwd]").val()==''){
                $('#err1').html('请输入旧密码').show();
                return false;
            }else{
                $('#err1').html('').hide();
            }
            //新密码
            if($("input[name=newupwd]").val()==''){
                $('#err2').html('请输入新密码').show();
                return false;
            }else{
                $('#err2').html('').hide();
            }

            //新旧密码不能相同
            if($("input[name=oldupwd]").val()==$("input[name=newupwd]").val()){
                $('#err2').html('新密码不能跟旧密码相同').show();
                return false;
            }else{
                $('#err2').html('').hide();
            }

            //重复密码
            if($("input[name=roldupwd]").val()!=$("input[name=newupwd]").val()){
                $('#err3').html('两次密码不一致').show();
                return false;
            }else{
                $('#err3').html('').hide();
            }
            
            //异步修改密码
            op = $("input[name=oldupwd]").val();
            np = $("input[name=newupwd]").val();
            // $.post('__CONTROL__/'+'ajaxFix',{'op':op,'np':np},function(data){
            //    alert('111');
            // },"json");
            $.post("__CONTROL__/ajaxFix",{'op':op,'np':np},function(data){
               
                switch(data.status){
                    case 1:
                    alert('修改成功');
                    histroy.go(0);
                    break;
                    case 2:
                    alert('修改失败');
                    return false;
                    break;
                    case 3:
                    $('#err1').html('旧密码错误').show();
                    return false;
                    break;
                    default:
                    alert('出错了');
                    return false;
                }
            },'json');
            
            return false;
        });
    });

</script>
</body>
</html>